//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ScientificWorkflow.TridentModelSL
{
    using System;
    using service = Microsoft.Research.ScientificWorkflow.TridentSilverlightService;
    using System.Globalization;

    /// <summary>
    /// Model for monitor's workflow parameters Tab.
    /// </summary>
    public class WorkflowOutputModel
    {
        /// <summary>
        /// 
        /// </summary>
        private bool isFinal;

        /// <summary>
        /// Name of the activity which generated the Data product.
        /// </summary>
        private string activityName;

        /// <summary>
        /// 
        /// </summary>
        private string activityUniqueName;

        /// <summary>
        /// Name of the parameter which generated the Data product.
        /// </summary>
        private string parameterName;

        /// <summary>
        /// Name of the Data product.
        /// </summary>
        private string dataproductName;

        /// <summary>
        /// Initializes a new instance of the <see cref="WorkflowOutputModel"/> class.
        /// </summary>
        public WorkflowOutputModel()
        { }

        /// <summary>
        /// Initializes a new instance of the <see cref="WorkflowOutputModel"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        public WorkflowOutputModel(service.DataProductModel source)
        {
            ActivityName = source.activityName;
            ActivityUniqueName = source.activityUniqueName;
            DataProductName = source.dataproductName;
            ParameterName = source.parameterName;
            Id = source.id;
            IsFinal = source.isFinal;
        }

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>The id.</value>
        public Guid Id { get; set; }

        /// <summary>
        /// Gets or sets the display name.
        /// </summary>
        /// <value>The display name.</value>
        public string DisplayName
        {
            get
            {
                return string.Format(CultureInfo.CurrentCulture, "{0}.{1}", this.activityName, this.parameterName);
            }
        }

        /// <summary>
        /// Gets or sets the name of the activity.
        /// </summary>
        /// <value>The name of the activity.</value>
        public string ActivityName
        {
            get { return this.activityName; }
            set
            {
                if (this.activityName != value)
                {
                    this.activityName = value;
                }
            }
        }

        /// <summary>
        /// Gets or sets the name of the parameter.
        /// </summary>
        /// <value>The name of the parameter.</value>
        public string ParameterName
        {
            get { return this.parameterName; }
            set
            {
                if (this.parameterName != value)
                {
                    this.parameterName = value;
                }
            }
        }

        /// <summary>
        /// Gets or sets the name of the dataproduct.
        /// </summary>
        /// <value>The name of the dataproduct.</value>
        public string DataProductName
        {
            get { return this.dataproductName; }
            set
            {
                if (this.dataproductName != value)
                {
                    this.dataproductName = value;
                }
            }
        }

        /// <summary>
        /// Gets or sets the name of the activity unique.
        /// </summary>
        /// <value>The name of the activity unique.</value>
        public string ActivityUniqueName
        {
            get { return this.activityUniqueName; }
            set
            {
                if (this.activityUniqueName != value)
                {
                    this.activityUniqueName = value;
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is final.
        /// </summary>
        /// <value><c>true</c> if this instance is final; otherwise, <c>false</c>.</value>
        public bool IsFinal
        {
            get
            {
                return isFinal;
            }
            set
            {
                isFinal = value;
            }
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            string overiddenString = string.Format(CultureInfo.CurrentCulture, "{0}.{1}.{2}", this.ActivityName, this.ParameterName, this.DataProductName);
            if (string.IsNullOrEmpty(overiddenString))
            {
                return base.ToString();
            }
            else
            {
                return overiddenString;
            }
        }
    }
}
